import 'package:flutter/material.dart';
import '../../../services/screenAdapter.dart';

import 'package:get/get.dart';

import '../controllers/login_controller.dart';

class LoginView extends GetView<LoginController> {
  const LoginView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          Container(
            width: ScreenAdapter.width(1920),
            height: ScreenAdapter.height(1080),
            decoration: const BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
                colors: [Color(0xFF2E3192), Color(0xFF1BFFFF)],
              ),
            ),
          ),
          Positioned(
            left: 0,
            right: 0,
            top: 0,
            bottom: 0,
            child: Align(
              alignment: Alignment.center, // 显式居中
              child: SizedBox(
                width: ScreenAdapter.width(500),
                height: ScreenAdapter.height(600),
                child: Column(
                  children: [
                    const Text(
                      '登录系统',
                      style: TextStyle(fontSize: 32, color: Colors.white),
                    ),
                    const SizedBox(height: 20),
                    TextField(
                      controller: controller.phoneController,
                      cursorColor: Color.fromRGBO(240, 115, 49, 1),
                      decoration: const InputDecoration(
                        hintText: '请输入用户名',
                        hintStyle: TextStyle(color: Colors.grey),
                        filled: true,
                        fillColor: Colors.white,
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                        ),
                        focusedBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                          borderSide: BorderSide(
                            color: Colors.blue,
                            width: 1.0,
                          ),
                        ),
                      ),
                    ),
                    const SizedBox(height: 20),
                    TextField(
                      controller: controller.passController,
                      obscureText: true,
                      cursorColor: Color.fromRGBO(240, 115, 49, 1),
                      decoration: const InputDecoration(
                        hintText: '请输入密码',
                        hintStyle: TextStyle(color: Colors.grey),
                        filled: true,
                        fillColor: Colors.white,
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                        ),
                        focusedBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                          borderSide: BorderSide(
                            color: Colors.blue,
                            width: 1.0,
                          ),
                        ),
                      ),
                    ),
                    const SizedBox(height: 20),
                    ElevatedButton(
                      style: ButtonStyle(
                        backgroundColor: WidgetStateProperty.all(
                          Color.fromRGBO(240, 115, 49, 1),
                        ),
                        foregroundColor: WidgetStateProperty.all(Colors.white),
                        shape: WidgetStateProperty.all(
                          RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(
                              ScreenAdapter.height(70),
                            ),
                          ),
                        ),
                      ),
                      onPressed: () async {
                        await controller.doLogin();
                      },
                      child: SizedBox(
                        width: ScreenAdapter.width(400),
                        height: ScreenAdapter.height(50),
                        child: const Center(child: Text('登录')),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
